package com.market.plus.core.domain;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

@Entity
@Table(name = "AVATAR")
@NamedQueries( { @NamedQuery(name = Avatar.FIND_ALL, query = "SELECT avatar FROM Avatar avatar") })
public class Avatar implements Persistable, StatusInfo {

   public static final String FIND_ALL = "AVATAR.FIND_ALL";

   @Id
   @GeneratedValue(strategy = GenerationType.TABLE, generator = "GEN_AVATAR")
   @TableGenerator(name = "GEN_AVATAR", table = "SEQUENCE_LIST", allocationSize = 1, initialValue = 1, pkColumnName = "NAME", valueColumnName = "NEXT_SEQUENCE", pkColumnValue = "AVATAR")
   @Column(name = "AVATAR_ID")
   private Long id;

   @OneToOne(cascade=CascadeType.ALL)
   @JoinColumn(name="CONTENTFILE_ID")
   private ContentFile contentFile;

   @Column(name = "STATUS")
   @Enumerated(EnumType.ORDINAL)
   private Status status;

   public Avatar() {
   }

   public Long getId() {
      return id;
   }

   public void setId(Long id) {
      this.id = id;
   }

   public Status getStatus() {
      return status;
   }

   public void setStatus(Status status) {
      this.status = status;
   }

   public ContentFile getContentFile() {
      return contentFile;
   }

   public void setContentFile(ContentFile contentFile) {
      this.contentFile = contentFile;
   }

   @Override
   public boolean equals(Object obj) {
      Avatar propertyCompare = (Avatar) obj;
      if (this.getId().longValue() == propertyCompare.getId().longValue()) {
         return true;
      }
      return false;
   }
}
